import 'package:convex_bottom_bar/convex_bottom_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shenfuhui/config/config.dart';
import 'package:shenfuhui/tabview/home_index.dart';
import 'package:shenfuhui/tabview/home_mine.dart';

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  List<TabItem> tabItems = [
    const TabItem(icon: Icons.local_mall_outlined, title: '商城'),
    const TabItem(icon: Icons.perm_contact_cal_outlined, title: '我的'),
  ];

  List<Widget> tabViews = [
    const HomeIndex(),
    const HomeMine(),
  ];

  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // body: tabViews[_currentIndex],

      body: IndexedStack(
        index: _currentIndex,
        children: tabViews,
      ),

      bottomNavigationBar: ConvexAppBar(
        items: tabItems,
        backgroundColor: Config.colorWhite,
        color: Config.colorText2,
        activeColor: Config.colorMain,
        style: TabStyle.react,
        elevation: 5.w,
        top: -16,
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
      ),
    );
  }
}
